package cc.aliza.lib.mongo.core.encoder;

import cc.aliza.lib.mongo.core.annotations.Property;

import java.lang.reflect.Field;

/**
 * 『给时光以生命·给岁月以文明』
 *
 * @author Zhang Jing (byrdkm17@gmail.com).
 */
public class PropertyEncoder extends AbstractEncoder {

    public PropertyEncoder(Object obj, Field field) {
        super(obj, field);
    }

    @Override
    public String getFieldName() {
        Property property = field.getAnnotation(Property.class);
        return property == null ? field.getName() : getFieldRealName(property.name());
    }

    @Override
    public Object encode() {
        return value;
    }
}
